home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / crsbas.zip / CROSSBAS.DOC < prev    next >
Text File  |  1990-12-01  |  44KB  |  1,085 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                                    CrossBas Manual
  23.  
  24.                        Power-BASIC Cross-Reference List Creator
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.                                   November 13, 1989 (1990)
  33.                                   (c) Lester L. Noll
  34.                               CompuServe Id:  72250,2551
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.                                      CrossBas.exe
  44.                                     version 1.00P
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                                     ContentsContents
  58.  
  59.  
  60.                   1  Disclaimer  . . . . . . . . . . . . . . . . . . 1
  61.                   2  Copyright and Usage . . . . . . . . . . . . . . 1
  62.                   3  Introduction  . . . . . . . . . . . . . . . . . 1
  63.                   4  Running CrossBas  . . . . . . . . . . . . . . . 2
  64.                   5  Command Line Options  . . . . . . . . . . . . . 2
  65.                   6  Changing Defaults File  . . . . . . . . . . . . 5
  66.                   7  The Summary Report  . . . . . . . . . . . . . . 6
  67.                   8  What CrossBas Does  . . . . . . . . . . . . . . 8
  68.                      8.1  Initialize . . . . . . . . . . . . . . . . 8
  69.                      8.2  InitScreen . . . . . . . . . . . . . . . . 8
  70.                      8.3  ReadCmdLine  . . . . . . . . . . . . . . . 9
  71.                      8.4  OpenFiles  . . . . . . . . . . . . . . . . 9
  72.                      8.5  CalcFileNames  . . . . . . . . . . . . . . 9
  73.                      8.6  ReadDefaults . . . . . . . . . . . . . . . 9
  74.                      8.7  CheckStringSpace . . . . . . . . . . . .  10
  75.                      8.8  CalcWordArraySize  . . . . . . . . . . .  10
  76.                      8.9  PrintScreenTop . . . . . . . . . . . . .  10
  77.                      8.10  ReadAndParseData  . . . . . . . . . . .  10
  78.                      8.11  PrintScreen1  . . . . . . . . . . . . .  10
  79.                      8.12  Compare . . . . . . . . . . . . . . . .  11
  80.                      8.13  PrintScreen2  . . . . . . . . . . . . .  11
  81.                      8.14  Sort  . . . . . . . . . . . . . . . . .  11
  82.                      8.15  PrintScreen3  . . . . . . . . . . . . .  11
  83.                      8.16  PrintList . . . . . . . . . . . . . . .  11
  84.                      8.17  PrintReportBtm  . . . . . . . . . . . .  12
  85.                      8.18  PrintScreen4  . . . . . . . . . . . . .  12
  86.                      8.19  End Routines  . . . . . . . . . . . . .  12
  87.  
  88.                Appendix A  CrossBas Files                           13
  89.  
  90.                Appendix B  Modification History                     15
  91.  
  92.                Appendix C  Power-BASIC Reserved Words               17
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.                                           i
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.                                          ii
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.                                     FiguresFigures
  186.  
  187.  
  188.                Figure 1: Summary Report Example  . . . . . . . . . . 8
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.                                          iii
  237.  
  238.  
  239.           CROSSBAS.DOC                CrossBas Manual                page 1
  240.  
  241.  
  242.  
  243.           1  Disclaimer          1  Disclaimer
  244.  
  245.  
  246.                Hear ye, hear ye!  Be it known that the author hereby
  247.           disclaims all warranties expressed or implied as to the quality
  248.           or performance of this program.  The author will not be held
  249.           liable for any lost profits, lost savings or any other direct,
  250.           indirect, incidental or consequential damages resulting from the
  251.           use of this program.  Your use of this program constitutes your
  252.           agreement to this disclaimer and your release of the author from
  253.           any form of liability or litigation.  (Really gives you
  254.           confidence, huh?)
  255.  
  256.  
  257.           2  Copyright and Usage          2  Copyright and Usage
  258.  
  259.  
  260.                This program, as well as its accompanying files and
  261.           documents, is copyright by the author, Lester L. Noll.  You are
  262.           free to use and distribute it as you wish as long as you charge
  263.           no payment, either money or otherwise, for it.  Also, you must
  264.           keep all the associated files together.  The files are listed in
  265.           Appendix I.  Use PKUNZIP to unarchive.
  266.  
  267.                If you have any questions, comments or suggestions about
  268.           this program, feel free to contact me at CompuServe:
  269.  
  270.                     Lester L. Noll
  271.                     [72250,2551]
  272.  
  273.  
  274.           3  Introduction          3  Introduction
  275.  
  276.  
  277.                CrossBas will scan a Power-BASIC source file and create a
  278.           cross-reference table of variable names, labels, procedure and
  279.           function names versus the physical line numbers where those names
  280.           occur.
  281.  
  282.                To do this we must first read in all words in the file.  We
  283.           can skip text to the right of "REM" statements or "'" remark
  284.           identifiers; text to the right of "DATA" statements; text between
  285.           quote marks;  numbers;  and operators.
  286.  
  287.                After the program words are read in, we compare them with
  288.           Power-BASIC reserved words and metastatements.  We keep only
  289.           those that are not Power-BASIC words.
  290.  
  291.                Finally, we alphabetize the remaining words and print them
  292.           out, one word to a line, followed by the physical source file
  293.           line number(s) where these words are found.  The list is sorted
  294.           without regard to case.
  295.  
  296.  
  297.           CROSSBAS.DOC                CrossBas Manual                page 2
  298.  
  299.  
  300.  
  301.                We print the list to an ASCII file and allow the user some
  302.           control over its format.  You may either print it to your printer
  303.           using the DOS PRINT or TYPE filename.ext>PRN commands or you may
  304.           use a print program such as Norton's LP.
  305.  
  306.                At the end of the file is a summary report showing
  307.           processing times, number of words processed and a few
  308.           calculations that may be helpful for customizing CrossBas to your
  309.           own programming characteristics.
  310.  
  311.  
  312.           4  Running CrossBas          4  Running CrossBas
  313.  
  314.  
  315.                Run CrossBas from the DOS command line.  There is no
  316.           interactive mode.  If you enter "CROSSBAS" with no command line
  317.           parameters, CrossBas will print a short message showing proper
  318.           syntax and the optional switches.
  319.  
  320.  
  321.           5  Command Line Options          5  Command Line Options
  322.  
  323.  
  324.                The only required command line parameter is the input file
  325.           (source file) path/name.  The output file path/name and switches
  326.           are optional.  If no output file is entered, I append ".cb" to
  327.           the input file name to create an output file name.  If a file
  328.           having the same name as output file already exists, I write over
  329.           it -- so be warned.
  330.  
  331.                Command line options can be entered in any order.  In fact,
  332.           the only rule is that the input file path/name must be entered
  333.           before the output file path/name.  You may enter switches, one
  334.           after the other, without separating spaces.  If, however, you
  335.           enter a switch before a file path/name you must leave at least
  336.           one space between the file path/name and the preceding switch.
  337.  
  338.           Syntax:
  339.  
  340.           crossbas infile[.ext][outfile][.ext][/bw][/p][/u][/s][/l:n][/w:n]
  341.  
  342.  
  343.           Switches:
  344.                /bw  Set screen colors to black and white.
  345.                /p   Paginate output file and print page headers.
  346.                /u   Print variables to output file in upper case.
  347.                /s   Print the list to the screen as well as to file.
  348.                /l:n Set the printer left margin to n columns.
  349.                /w:n Override CrossBas' word array dimension calculation.
  350.  
  351.  
  352.           CROSSBAS.DOC                CrossBas Manual                page 3
  353.  
  354.  
  355.  
  356.           Input File                    infile                   [required]
  357.  
  358.                The input file path/name must be a valid DOS pathname.  If
  359.           no path is entered, the default path is assumed.  If the input
  360.           file path/name is not found, CrossBas prints an appropriate
  361.           message and quits.
  362.  
  363.  
  364.           Output File                   outfile                  [optional]
  365.  
  366.                The output file path/name must be formed using valid DOS
  367.           pathname and filename syntax.  If no path is entered, the default
  368.           is assumed.  If no output file path/name is entered or if the
  369.           entered output file path/name is invalid, I append ".cb" to the
  370.           input file path/name for the output file.
  371.  
  372.                I do not check if a file with the same name already exists.
  373.           If one does exist, I write over it.  If you have a main file with
  374.           the extension ".bas" and an include file with the extension
  375.           ".inc" you are responsible for providing output file names that
  376.           do not conflict with each other.  By allowing CrossBas to use its
  377.           default output file name, both cross-reference files would have
  378.           the same name, which means the second one would overwrite the
  379.           first.
  380.  
  381.  
  382.           Black & White                    /bw                   [optional]
  383.  
  384.                The black and white switch, /bw, sets the screen color to
  385.           black and white.  The default screen colors are yellow (#14)
  386.           foreground on a blue (#1) background.  The upper and lower screen
  387.           lines (lines 1 and 25) use the same colors but with foreground
  388.           and background colors reversed.  Since only colors numbered 0
  389.           through 7 are allowed for background colors, and since yellow is
  390.           14, the upper and lower screen line colors are blue foreground
  391.           and brown (#6) background (14 minus 8).
  392.  
  393.  
  394.           Paginate                       /p                      [optional]
  395.  
  396.                The paginate switch, /p, causes the output file to be
  397.           written with page breaks and page headers.  The header contains
  398.           the current system date, the page number and the source file
  399.           name.  To print a paginated file, type either "TYPE filename.ext
  400.           > PRN" or "PRINT filename.ext" from the DOS command line.  Blank
  401.           lines and form-feeds are inserted in the output file in order to
  402.           leave two blank lines at the top of the page and three blank
  403.           lines at the bottom of the page.  The header appears on line
  404.           three of each page, followed by one blank line. On line five is a
  405.           column header indicating "Variable/Label/Proc" name on the left,
  406.           and "Physical Line Number" on the right.
  407.  
  408.  
  409.           CROSSBAS.DOC                CrossBas Manual                page 4
  410.  
  411.  
  412.  
  413.                If the paginate switch is not selected, the output file is
  414.           printed without page breaks or headers.  This method may be
  415.           preferable if you use a print formatter like Norton Utilities'
  416.           LP, which does its own page formatting.
  417.  
  418.                In either case, the summary report will be printed on the
  419.           last page without breaks.  Thus if there are not enough lines to
  420.           print the entire report on what remains of the last page, I
  421.           insert a form-feed and print it on a new page.
  422.  
  423.  
  424.           Upper-case                      /u                     [optional]
  425.  
  426.                The upper-case switch, /u, causes the variable, label,
  427.           procedure and function names to be written to the output file in
  428.           all upper-case.  If this switch is selected, two words, the same
  429.           in name but written in different case, would only appear once in
  430.           the output listing.  If this switch is not selected, for example,
  431.           "Label1:", LABEL1:" and "label1:" would all be listed separately.
  432.           If you use case to clarify your labels, such as,
  433.           "ThisIsLabelOne:", you will probably choose to not use this
  434.           switch.  Sorting is always done in upper-case order, therefore
  435.           "AAA", "aaa" and "Aaa" would be treated equally.  (Because I use
  436.           UCASE$(word$) to sort the list, the three previous examples could
  437.           appear in any order.)
  438.  
  439.  
  440.           Screen                        /s                       [optional]
  441.  
  442.                The screen switch, /s, causes the sorted list to print to
  443.           the screen at the same time it prints to the output file.  After
  444.           22 lines print to the screen, the scroll stops with a "...Press Q
  445.           to Quit screen list, any other key to continue" message.  When
  446.           you press a key the scroll continues for 22 more lines.  If you
  447.           press <Q> or <ESC> the screen list stops but output to output
  448.           file continues until the list print is completed.
  449.  
  450.           [Note:  The list prints to the output file at the same time it
  451.           prints to the screen.  Therefore, if you decide you don't want to
  452.           see anymore and press <Ctrl><Break>, you will also abort the
  453.           write to file.]
  454.  
  455.  
  456.           Left Margin                    /l:n                    [optional]
  457.  
  458.                The left margin switch and parameter, /l:n, will insert a
  459.           printer setup string at the top of the output file to set the
  460.           left margin at "n" columns.  The left margin range is 0 to 8
  461.           columns.  Since the page width is 72 columns, having a left
  462.           margin of more than 8 would push the page off the edge of an 80
  463.           column page.  If you enter a left margin greater than 8, the
  464.           value defaults to 8.
  465.  
  466.  
  467.           CROSSBAS.DOC                CrossBas Manual                page 5
  468.  
  469.  
  470.  
  471.           [Note:  I use the Epson escape sequence, <ESC> "l" n, where n
  472.           equals the left margin column.  If you have a different printer
  473.           you must modify the code or not use this option.]
  474.  
  475.  
  476.           Word Array Dimension Override     /w:n                 [optional]
  477.  
  478.                The word dimension override switch and parameter, /w:n, will
  479.           override CrossBas' internal word dimension calculation.  You may
  480.           need to use this if the source file is less densely commented
  481.           than CrossBas expects.  Let me explain.
  482.  
  483.                CrossBas uses a string array to hold all the words read in
  484.           from the input file.  I use two default parameters to calculate
  485.           how many words to dimension the word array for.  The two
  486.           parameters are Average Word Length and Packing Factor.  The word
  487.           array will hold all of the non-comment, non-number words found in
  488.           a source file.  To calculate the word array dimension, I first
  489.           read the source file size in bytes.  Then I multiply it by the
  490.           Packing Factor.  The Packing Factor is a number, less than 1,
  491.           that represents the ratio of non-comment, non-number word bytes
  492.           versus the total bytes in the file.  Then I divide the result by
  493.           the Average Word Length.  These two parameters are read in from
  494.           the defaults file, CROSSBAS.DEF, when CrossBas first starts.
  495.  
  496.                Normally, this calculation is accurate enough.  However, if
  497.           the actual packing factor of a particular source file is
  498.           considerably greater than the default or the actual average word
  499.           length is considerably smaller than the default, you may need to
  500.           use this switch.
  501.  
  502.                To use the /w:n switch:  approximate the number of words,
  503.           both Power-BASIC reserved words and non-reserved words: labels,
  504.           procedure names, function names, variable names, in the source
  505.           file.  Do not include comment words, data words or numbers in the
  506.           total.  This number will become the 'n' parameter of the word
  507.           array dimension switch.
  508.  
  509.  
  510.           6  Changing Defaults File          6  Changing Defaults File
  511.  
  512.  
  513.                You can change the defaults file with any ASCII editor.
  514.           When you run CrossBas the first time it will create CROSSBAS.DEF.
  515.           The next time it runs it will look for that file in the default
  516.           directory.  If it finds it, CrossBas will read in two parameters:
  517.           Average Word Length, and Packing Factor.
  518.  
  519.                These two parameters are both in the first line of the
  520.           defaults file, separated by a comma.  The rest of the defaults
  521.           file contains a few lines of text explaining the default
  522.           parameters.  You may do anything you like to this file except
  523.           modify the format of the first line.  Change the values, if you
  524.           like but be sure the first number, the Average Word Length, is a
  525.  
  526.  
  527.           CROSSBAS.DOC                CrossBas Manual                page 6
  528.  
  529.  
  530.  
  531.           number greater than one.  Likewise, the second number, the
  532.           Packing Factor, must be a decimal number less than one.  The two
  533.           numbers must be separated by a comma.
  534.  
  535.                To determine the best default parameters, check the summary
  536.           report, at the end of your CrossBas listings.  It shows the
  537.           default values used by CrossBas.  It also shows the actual
  538.           parameters that CrossBas found after reading in the words from
  539.           the source file.  After CrossBas-ing a few of your source files,
  540.           you can get an idea of the Average Word Lengths and Packing
  541.           Factors you use in your files.
  542.  
  543.  
  544.           7  The Summary Report          7  The Summary Report
  545.  
  546.  
  547.                A summary report appears at the end of the CrossBas cross-
  548.           reference file listing.
  549.  
  550.                The top two-thirds of the report is the same as what
  551.           CrossBas prints to the screen as it processes the source file.
  552.  
  553.                Your command line options are listed on the top two rows.
  554.  
  555.                The next three lines show the read and parse procedure
  556.           statistics.  This is where CrossBas reads in source file text
  557.           lines, parses them into words and saves all the words that are
  558.           not comments (REM or '), data words (DATA), operators (*, AND, =,
  559.           etc.), or numbers.  The remaining words get stored in a word
  560.           array.  Line number references for each of the saved words are
  561.           stored in a line number array.  These three lines show the number
  562.           of lines in the source file, the number of words saved to the
  563.           word array and the start, end and elapsed processing times.
  564.  
  565.                The next three lines show the compare procedure statistics.
  566.           Up to this point, the word array contains Power-BASIC reserved
  567.           words, label names, variable names, subprogram (SUB) names and
  568.           function (FN) names.  Now CrossBas compares each word in the word
  569.           array with Power-BASIC reserved words.  If the words compare we
  570.           do not save them.  These three report lines show the number of
  571.           words compared, the number of non-Power-BASIC words in the source
  572.           file (if the same word appears 5 times then it is counted as 5
  573.           words at this point) and the start, end and elapsed processing
  574.           times.
  575.  
  576.                The next two lines show the sort procedure statistics.
  577.           CrossBas sorts the remaining words in alphabetical order, without
  578.           regard for case.  These two report lines show the number of words
  579.           sorted and the start, end and elapsed processing times.
  580.  
  581.                The next two lines show the printing to file statistics.
  582.           CrossBas prints the sorted words to the output file in the manner
  583.           specified by the command line options.  These two lines show the
  584.           number of unique words (if the same word appears 5 times it is
  585.  
  586.  
  587.           CROSSBAS.DOC                CrossBas Manual                page 7
  588.  
  589.  
  590.  
  591.           counted as only one unique word) printed to the output file and
  592.           the start, end and elapsed processing times.
  593.  
  594.                The next line shows the total CrossBas processing times:
  595.           start, end and elapsed, from the start of the read and parse
  596.           procedure to the end of the print to file procedure.
  597.  
  598.                Next we have an analysis of the source file.  Use this to
  599.           help you customize your CROSSBAS.DEF file.
  600.  
  601.                The total number of bytes used by the word array is taken at
  602.           the time when it contained both non-reserved words (labels,
  603.           procedures, functions, variables) and Power-BASIC reserved words.
  604.           I use this figure (actually a projection of this figure using the
  605.           input file length and the default Packing Factor) to determine if
  606.           there will be enough string space to process the source file.
  607.  
  608.                The default word array dimension is the number used to
  609.           dimension the word array.  This is a calculated value unless you
  610.           included a command line override (/w:n).  The command line
  611.           override is shown at the top of the report.  If no override
  612.           option was included, the screen report will show "No o/r."
  613.  
  614.                The actual word array dimension is the actual number of
  615.           words found in the source file.
  616.  
  617.                The default Average Word Length is the number read in from
  618.           the CROSSBAS.DEF file.  I use this, along with the default
  619.           Packing Factor, to calculate the default word array dimension.
  620.  
  621.                The actual average word length is the actual average word
  622.           length of the non-reserved words in the source file.  I guess
  623.           that explains itself.
  624.  
  625.                The default Packing Factor is the number read in from the
  626.           CROSSBAS.DEF file (a number less than one).  I use this, along
  627.           with the Average Word Length, to calculate the word array
  628.           dimension.  I use this also to determine if there is enough
  629.           string space to process the source file.
  630.  
  631.                Finally, we list the source and output file names and sizes.
  632.  
  633.  
  634.           CROSSBAS.DOC                CrossBas Manual                page 8
  635.  
  636.  
  637.  
  638.                                -+-+-+- Summary Report -+-+-+-
  639.  
  640.           Options: Upper-case:  No     Screen:   No       Paginate:  Yes
  641.                    Left Margin: 6      ArrayDim: No o/r
  642.  
  643.           Read:      448 lines from source file CROSSBAS.INC
  644.           Found:     919 non-comment words.
  645.           Times:     Start: 15:06:59  End: 15:07:16  Elapsed: 00:00:17
  646.  
  647.           Compared:  919 non-comment words from source file CROSSBAS.INC
  648.           Found:     432 non-reserved words (variables, labels, procedures)
  649.           Times:     Start: 15:07:17  End: 15:07:27  Elapsed: 00:00:10
  650.  
  651.           Sorted:    432 non-reserved words (variables, labels, procedures)
  652.           Times:     Start: 15:07:28  End: 15:08:01  Elapsed: 00:00:33
  653.  
  654.           Printed:   93 unique, non-reserved words to CROSSBAS.CBI
  655.           Times:     Start: 15:08:02  End: 15:08:04  Elapsed: 00:00:02
  656.  
  657.           Totals:    Start: 15:06:59  End: 15:08:04  Elapsed: 00:01:05
  658.  
  659.           Word Array Size:   4,852 bytes
  660.           Default Word Array Dim.:  1,124 wds  Actual Word Array Dim.:    919 wds
  661.           Default Avg.Word Length:      6 byt  Actual Avg.Word Length:      5 byt
  662.           Default Packing Factor:   45.00 %    Actual Packing Factor:   32.35 %
  663.  
  664.           Source,    CROSSBAS.INC, File size:  14,998 bytes
  665.           Cross-Ref, CROSSBAS.CBI, File size:   6,984 bytes
  666.  
  667.  
  668.                               Figure 1: Summary Report Example                              Figure 1
  669.  
  670.  
  671.  
  672.           8  What CrossBas Does          8  What CrossBas Does
  673.  
  674.  
  675.                CrossBas' main program flow consists of a series of GOSUB-
  676.           type subroutines.  The following is a description of each one in
  677.           the order in which they occur.
  678.  
  679.           8.1  Initialize          8.1  Initialize
  680.  
  681.                Initialize the screen type and color variables.  Most of my
  682.           numbers will be integers so I define all number variables as
  683.           integers.  Set up an error trap.
  684.  
  685.           8.2  InitScreen          8.2  InitScreen
  686.  
  687.                Print initializing message to the screen.
  688.  
  689.  
  690.           CROSSBAS.DOC                CrossBas Manual                page 9
  691.  
  692.  
  693.  
  694.           8.3  ReadCmdLine          8.3  ReadCmdLine
  695.  
  696.                Read in the DOS command line parameters.  Set up the
  697.           paginate, screen print and upper-case flags, and the left margin
  698.           and word array dimension variables.  Get input file path/name.
  699.           The second parameter that is not a valid switch is assumed to be
  700.           the output file path/name.  If no input file path/name is found
  701.           then print the appropriate message to the screen and die.
  702.  
  703.           8.4  OpenFiles          8.4  OpenFiles
  704.  
  705.                Attempt to open the input and output files.  If I fail while
  706.           opening the input file, I check to see if it has an extension.
  707.           If it doesn't, I append ".bas" and try again.  If I fail again, I
  708.           print the appropriate message to the screen and die.
  709.  
  710.                If the input I open the input file ok, I next attempt to
  711.           open the output file.  If no file path/name is given I append
  712.           ".cb" to the end of the input file (after stripping the
  713.           extension, if one exists).  If I fail, I somewhere along the way,
  714.           I print the appropriate message to the screen and die.  If I am
  715.           successful I close the output file until I'm ready to write to
  716.           it.
  717.  
  718.           [Note:  A previously existing file with the same name as the
  719.           output file is, at this point, replaced by a file of 0 bytes.]
  720.  
  721.           8.5  CalcFileNames          8.5  CalcFileNames
  722.  
  723.                Strip off the drive and directory specs from the input and
  724.           output file path/names.  I use these stripped names for output
  725.           file page headers and screen and file report headers.
  726.  
  727.           8.6  ReadDefaults          8.6  ReadDefaults
  728.  
  729.                Read in the default values for Average Word Length and
  730.           Packing Factor from the defaults file, CROSSBAS.DEF.  If this
  731.           file does not exist, I make one.
  732.  
  733.                If you run CrossBas from other than its home directory, it
  734.           will not find its defaults file and will create a new one in the
  735.           default directory.  This won't bother CrossBas but if you have
  736.           modified the CROSSBAS.DEF and are assuming your modified default
  737.           parameters will be used, you may be surprised.  In that case, you
  738.           had better change directory to the CrossBas directory and run the
  739.           program from there.  See the default section for more on
  740.           modifying the defaults file.
  741.  
  742.  
  743.           CROSSBAS.DOC                CrossBas Manual               page 10
  744.  
  745.  
  746.  
  747.           8.7  CheckStringSpace          8.7  CheckStringSpace
  748.  
  749.           [Note:  I removed this subroutine from the Power-BASIC version of
  750.           CrossBas because of PB's increased string space capacity.  To use
  751.           it with Turbo-BASIC, reinstall.]
  752.  
  753.                Check to see that there is enough free string space for
  754.           storing the anticipated input file words.  I read the input file
  755.           size and multiply it by the packing factor.  This should give me
  756.           the approximate number of bytes of non-comment, non-number words
  757.           in the input file.  Then I compare this "effective file size"
  758.           with the free string space.  If not enough string space, I print
  759.           the appropriate message to the screen and die.
  760.  
  761.           8.8  CalcWordArraySize          8.8  CalcWordArraySize
  762.  
  763.                First check to see if there is a command line Word Array
  764.           Dimension override (/w:n).  If so, use this value to dimension
  765.           the word array.
  766.  
  767.                If not calculate the approximate number of words in the
  768.           input file.  Find the effective input file size by multiplying
  769.           the input file size by the Packing Factor.  Then divide the
  770.           effective file size by the Average Word Length.  Packing Factor
  771.           and Average Word Length are values read in from the defaults file
  772.           in the ReadDefaults section.
  773.  
  774.           8.9  PrintScreenTop          8.9  PrintScreenTop
  775.  
  776.                Print the first few lines of the screen report.  These show
  777.           the input file name, less any drive or directory specifications;
  778.           the condition of the three command line switch flags; and the
  779.           option values for left margin and word array dimension override.
  780.  
  781.           8.10  ReadAndParseData          8.10  ReadAndParseData
  782.  
  783.                Read in the input file line by line, and parse out the non-
  784.           comment, non-number words.  Save these words, along with their
  785.           physical line numbers in separate arrays.  Keep a running total
  786.           of the bytes in the word array.  Print the current input file
  787.           line number and word to the status bar at the bottom of the
  788.           screen after every input file line.
  789.  
  790.                Also, check the free string space after each line and, if it
  791.           gets below 300 bytes (249 column limit per line, plus a few extra
  792.           for good measure) then abort and print the appropriate message to
  793.           the screen and die.
  794.  
  795.           8.11  PrintScreen1          8.11  PrintScreen1
  796.  
  797.                Print the number of lines read from the input file, the
  798.           number of non-comment, non-number words read and saved in the
  799.           word array, and the start and end times for the operation to the
  800.           screen.
  801.  
  802.  
  803.           CROSSBAS.DOC                CrossBas Manual               page 11
  804.  
  805.  
  806.  
  807.           8.12  Compare          8.12  Compare
  808.  
  809.                Compare the word array words with Power-BASIC reserved
  810.           words.  If the words are not Power-BASIC words, then save them
  811.           and their associated line-number array elements.  Print the
  812.           current word number to the status bar at the bottom of the screen
  813.           after every non-Power-BASIC word is saved.
  814.  
  815.                By checking the first letter of the word array word, I only
  816.           need to compare the word array word with Power-BASIC words
  817.           beginning with the same letter.  Save the non-Power-BASIC words
  818.           back into the same array but at a lower location.
  819.  
  820.                Lets say words 1,2 and 3 were Power-BASIC words.  Word 4 is
  821.           a label.  Therefore I save word array element number 4 back to
  822.           the same array but as element 1.  I also save the associated
  823.           line-number array element, in this case, 4 to 1.
  824.  
  825.                When I have compared all the words in the array, I blank out
  826.           the remaining, non-used elements in the word array to free up
  827.           string space.
  828.  
  829.           8.13  PrintScreen2          8.13  PrintScreen2
  830.  
  831.                Print the number of non-reserved words saved back to the
  832.           word array and the start and end times for the operation to the
  833.           screen.
  834.  
  835.           8.14  Sort          8.14  Sort
  836.  
  837.                Sort the remaining non-Power-BASIC words into alphabetical
  838.           order.  I use a modified bubble sort and compare upper-case
  839.           values of the words.  Print the current pass to the status bar at
  840.           the bottom of the screen.
  841.  
  842.                If there are J words in the word array then I make J-1
  843.           passes through the array, comparing a word with the word after
  844.           it.  If the words are in order, I check the next two words.  If
  845.           the words are out of order I swap them and their associated
  846.           line-number array elements.  If I make an entire pass without
  847.           making any swaps, then the sorting is complete.
  848.  
  849.           8.15  PrintScreen3          8.15  PrintScreen3
  850.  
  851.                Print the number of non-reserved words sorted and the start
  852.           and end times for the operation to the screen.
  853.  
  854.           8.16  PrintList          8.16  PrintList
  855.  
  856.                Print the word list to the output file.  The words are
  857.           listed in the left column.  The associated line numbers are
  858.           listed in the right eight columns.  Print the current page and
  859.           word number to the status bar at the bottom of the screen.
  860.  
  861.  
  862.           CROSSBAS.DOC                CrossBas Manual               page 12
  863.  
  864.  
  865.  
  866.             o  If a left margin (/l:n) is selected, print the printer setup
  867.                string at the top of the file.
  868.             o  If the upper-case switch (/u) is selected, convert the words
  869.                at print time.
  870.             o  If the screen print switch (/s) is selected, print the words
  871.                and line-numbers to the screen as they print to file.
  872.             o  If the paginate switch (/p) is selected, print a page header
  873.                at the top of each page and a form-feed at the bottom of
  874.                each page.
  875.  
  876.           8.17  PrintReportBtm          8.17  PrintReportBtm
  877.  
  878.                Print the summary report on the last page of the report.  If
  879.           the paginate switch (/s) is selected then if there is not enough
  880.           room on the last page for the entire report, send out a form-feed
  881.           and put it on a new page.  If the paginate switch is not selected
  882.           then send out a form-feed to start a new page.
  883.  
  884.                The report contains read, compare, sort and print
  885.           information, similar to that displayed on the screen.
  886.           Additionally I print total procedure times; source and output
  887.           file sizes; word array words and bytes, both default and actual;
  888.           and Packing Factors and Average Word Lengths, default and actual.
  889.  
  890.           8.18  PrintScreen4          8.18  PrintScreen4
  891.  
  892.                Print the number of unique words printed to the output file
  893.           and the start and end times for the operation to the screen.
  894.           Erase the status bar and print a "CrossBas finished" message.
  895.  
  896.           8.19  End Routines          8.19  End Routines
  897.  
  898.                Finally, I close all open files, flush the keyboard buffer
  899.           and wait for the user to acknowledge he has read the report
  900.           screen by pressing a key.  I included this step because some
  901.           versions of DOS erase the screen when they reload COMMAND.COM.
  902.  
  903.  
  904.           CROSSBAS.DOC                CrossBas Manual               page 13
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.                                      Appendix AAppendix A
  915.  
  916.                                    CrossBas FilesCrossBas Files
  917.  
  918.  
  919.                CrossBas uses the following files:
  920.  
  921.           CRSBAS.ZIP          CrossBas archive file that contains the
  922.                               CrossBas files.
  923.           CROSSBAS.EXE        CrossBas executable file.
  924.           CROSSBAS.DEF        CrossBas defaults file.  (CrossBas creates
  925.                               this file the first time it runs.)
  926.           CROSSBAS.BAS        CrossBas main source file.
  927.           CROSSBAS.INC        CrossBas subprograms file.
  928.           CROSSBAS.DOC        CrossBas document file (this file).
  929.  
  930.  
  931.           CROSSBAS.DOC                CrossBas Manual               page 14
  932.  
  933.  
  934.           CROSSBAS.DOC                CrossBas Manual               page 15
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.                                      Appendix BAppendix B
  945.  
  946.                                 Modification HistoryModification History
  947.  
  948.  
  949.           version 1.00P     12/ 1/90
  950.  
  951.           Uploaded CrossBas version 1.00P to CompuServe PCVENB, Spectra
  952.           forum.
  953.  
  954.           version 1.000     11/13/89
  955.  
  956.           Uploaded CrossBas version. 1.00 to CompuServe BPROGA forum,
  957.           LIB 9.
  958.  
  959.           KEYWORDS:  CROSS-REFERENCE, TABLE, LIST, NON-RESERVED WORDS,
  960.                      BASIC, CREF, XREF
  961.  
  962.           Description:   CrossBas will read in a Power-BASIC source file
  963.                          and create an alphabetized cross-reference listing
  964.                          of non-reserved words, i.e., variable, subprogram,
  965.                          function and label names, along with the physical
  966.                          line number(s) where they appear.  The list is
  967.                          printed to file.  Handy for cleaning up unused
  968.                          variable names, labels, etc.
  969.  
  970.  
  971.           CROSSBAS.DOC                CrossBas Manual               page 16
  972.  
  973.  
  974.           CROSSBAS.DOC                CrossBas Manual               page 17
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.                                      Appendix CAppendix C
  985.  
  986.                              Power-BASIC Reserved WordsPower-BASIC Reserved Words
  987.  
  988.  
  989.           $COM             BLOAD            DEF              FILEATTR()
  990.           $COM1            BSAVE            DEFBCD           FILES
  991.           $COM2                             DEFDBL           FIX()
  992.           $COMPILE         CALL             DEFEXT           FIXDIGITS
  993.           $CPU             CASE             DEFFIX           FLEXCHR$
  994.           $DEBUG           CBCD()           DEFFLX           FN
  995.           $DYNAMIC         CDBL()           DEFINT           FOR
  996.           $ELSE            CEIL()           DEFLNG           FRE()
  997.           $ENDIF           CTEXT()          DEFQUD           FREEFILE
  998.           $ERROR           CFIX()           DEFSNG           FROM
  999.           $EVENT           CHAIN            DEFSTR           FUNCTION
  1000.           $FLOAT           CHDIR            DELAY
  1001.           $IF              CHR$()           DELETE           GET
  1002.           $INCLUDE         CINT()           DESCEND          GET()
  1003.           $INLINE          CIRCLE()         DIM              GET$
  1004.           $LIB             CLEAR            DO               GOSUB
  1005.           $LINK            CLNG()           DRAW             GOTO
  1006.           $LIST            CLOSE            DYNAMIC
  1007.           $OPTION          CLS                               HEX$()
  1008.           $SEGMENT         COLLATE          ELSE
  1009.           $SOUND           COLOR            ELSEIF           IF
  1010.           $STACK           COM()            END              IMP
  1011.           $STATIC          COMMAND$         ENDMEM           IN
  1012.           $STRING          COMMON           ENVIRON          INCR
  1013.                            COS()            ENVIRON$()       INKEY$
  1014.           ABS()            CQUD()           EOF()            INP()
  1015.           ABSOLUTE         CSNG()           EQV              INPUT
  1016.           AND              CSRLIN           ERADR            INPUT #
  1017.           ANY              CVB()            ERASE            INPUT$()
  1018.           APPEND           CVD()            ERDEV            INSERT
  1019.           ARRAY            CVE()            ERDEV$           INSTAT
  1020.           AS               CVF()            ERL              INSTR()
  1021.           ASC()            CVI()            ERR              INT()
  1022.           ASCEND           CVL()            ERROR            INTERRUPT
  1023.           ASCII()          CVMD()           EXECUTE          IOCTL
  1024.           DATA             CVMS()           EXIT             IOCTL$
  1025.           AT               CVQ()            EXP()
  1026.           ATN()            CVS()            EXP10()          KEY
  1027.                                             EXP2()           KEY()
  1028.           BASE             DATA             EXTERNAL         KILL
  1029.           BEEP             DATE$            EXTRACT$()
  1030.           BIN$()           DECLARE                           LBOUND()
  1031.           BINARY           DECR             FIELD            LCASE$()
  1032.  
  1033.  
  1034.           CROSSBAS.DOC                CrossBas Manual               page 18
  1035.  
  1036.  
  1037.  
  1038.           LEFT$()          OCT$()           RESET            TALLY()
  1039.           LEN()            OFF              RESTORE          TAN()
  1040.           LET              ON               RESUME           THEN
  1041.           LINE             OPEN             RETURN           TIME$
  1042.           LINE()           OPTION           RIGHT$()         TIMER
  1043.           LIST             OR               RMDIR            TIMER()
  1044.           LOC()            OUT              RND              TO
  1045.           LOCAL            OUTPUT           RND()            TROFF
  1046.           LOCATE                            ROUND()          TRON
  1047.           LOF()            PAINT()          RSET
  1048.           LOG()            PALETTE          RTRIM$()         UBOUND()
  1049.           LOG10()          PEEK()           RUN              UCASE
  1050.           LOG2()           PEEK$()                           UCASE$()
  1051.           LOOP             PEEKI()          SAVE             UNTIL
  1052.           LPOS()           PEEKL()          SCAN             USING
  1053.           LPRINT           PEN              SCREEN           USING$()
  1054.           LPRINT #         PEN()            SCREEN()         USR
  1055.           LSET             PLAY             SEEK             USR0
  1056.           LTRIM$()         PLAY()           SEG              USR1
  1057.                            PMAP()           SELECT           USR2
  1058.           MAP              POINT()          SERVICE          USR3
  1059.           MAX()            POKE             SGN()            USR4
  1060.           MAX$()           POKE$            SHARED           USR5
  1061.           MAX%()           POKEI            SHELL            USR6
  1062.           MEMSET           POKEL            SIN()            USR7
  1063.           MID$()           POS              SORT             USR8
  1064.           MIN()            POS()            SOUND            USR9
  1065.           MIN$()           PRESET           SPACE$()
  1066.           MIN%()           PRINT            SPC()            VAL()
  1067.           MKDIR            PRINT #          SQR()            VARPTR()
  1068.           MKB$()           PSET()           STATIC           VARPTR$()
  1069.           MKD$()           PUBLIC           STEP             VARSEG()
  1070.           MKE$()           PUT              STICK()          VERIFY()
  1071.           MKF$()           PUT()            STOP             VIEW
  1072.           MKI$()           PUT$             STR$()           VIEW()
  1073.           MKL$()                            STRIG
  1074.           MKMD$()          RANDOM           STRIG()          WAIT
  1075.           MKMS$()          RANDOMIZE        STRING$()        WEND
  1076.           MKQ$()           READ             STRPTR()         WHILE
  1077.           MKS$()           REDIM            STRSEG()         WIDTH
  1078.           MOD              REG              SUB              WINDOW
  1079.           MTIMER           REG()            SWAP             WINDOW()
  1080.                            REM              SYSTEM           WITH
  1081.           NAME             REMOVE$()                         WRITE
  1082.           NEXT             REPEAT$()        TAB()            WRITE #
  1083.           NOT              REPLACE          TAGARRAY
  1084.                                                              XOR
  1085.